home *** CD-ROM | disk | FTP | other *** search
- head 1.1;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.1
- date 92.06.16.11.21.13; author jhh; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @/*
- * sethostname.c --
- *
- * Procedure to simulate Unix sethostname system call
- *
- * Copyright 1992 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that this copyright
- * notice appears in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.6 92/03/02 15:29:56 bmiller Exp $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include <sys/param.h>
- #include <sys/errno.h>
- #include "compatInt.h"
-
- /*
- *----------------------------------------------------------------------
- *
- * sethostname --
- *
- * Sets the host name.
- *
- * Results:
- * 0 is returned if the call was completed successfully.
- * Otherwise, -1 is returned and errno gives more information.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- int
- sethostname(name, namelen)
- char *name; /* New name of host. */
- int namelen; /* Length of name. */
- {
- char tmp[MAXHOSTNAMELEN];
- ReturnStatus status;
-
- if (namelen > MAXHOSTNAMELEN) {
- errno = EINVAL;
- return UNIX_ERROR;
- }
- /*
- * We allow names to lacking a terminating null character because the
- * Unix man pages are ambiguous as to whether it is needed.
- */
- if (name[namelen-1] != '\0') {
- if (namelen < MAXHOSTNAMELEN) {
- if (name[namelen] != '\0') {
- bcopy(name, tmp, namelen);
- tmp[namelen] = '\0';
- name = tmp;
- }
- } else {
- errno = EINVAL;
- return UNIX_ERROR;
- }
- }
- status = Sys_SetHostName(name);
- if (status != SUCCESS) {
- errno = Compat_MapCode(status);
- return UNIX_ERROR;
- }
- return 0;
- }
- @
-